package org.thread.test04.demo04;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author CSY
 * @date 2025 - 03 - 10
 */
public class MainTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCollable mc1 = new MyCollable(1,100);
        MyCollable mc2 = new MyCollable(101,900);
        MyCollable mc3 = new MyCollable(901,1000);

        FutureTask<Integer> ft1 = new FutureTask<>(mc1);
        FutureTask<Integer> ft2 = new FutureTask<>(mc2);
        FutureTask<Integer> ft3 = new FutureTask<>(mc3);
        Thread t1 = new Thread(ft1);
        Thread t2 = new Thread(ft2);
        Thread t3 = new Thread(ft3);
        t1.start();
        t2.start();
        t3.start();

        Integer sum = ft1.get()+ft2.get()+ft3.get();

        System.out.println(sum);

    }
}
